import { BrowserModule } from '@angular/platform-browser';
import { NgModule, ErrorHandler } from '@angular/core';
import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
import { MyApp } from './app.component';

import { HelloIonicPage } from '../pages/hello-ionic/hello-ionic';
import { ItemDetailsPage } from '../pages/item-details/item-details';
import { ListPage } from '../pages/list/list';

import { CeshiPage } from '../pages/ceshi/ceshi';  //right introduce
//手動引入page
import { HerosPage } from "../pages/heros/heros";
import { HeroDetailPage } from "../pages/hero-detail/hero-detail"  //引入了已经 单独的
import { TabTestPage } from '../pages/tab-test/tab-test';
import { Tab1 } from '../pages/tab-test/Tab1';
import { Tab2 } from '../pages/tab-test/Tab2';
import { SearchServicePage } from '../pages/search-service/search-service';
import { SearchDetailPage } from '../pages/search-detail/search-detail';
import { aboutPage } from '../pages/about/about';
import { NgDirectivePage } from '../pages/ng-directive/ng-directive';
//依赖注入页面
import{DependencyInjectionPage} from '../pages/dependency-injection/dependency-injection';
import { HeroesListComponent }   from '../pages/hero-list/hero-list';
import { HeroTaxReturnComponent }     from '../pages/hero-tax-return/hero-tax-return';
import { HeroesService }         from './heroes.service';
import { VillainsListComponent } from '../pages/villains-list/villains-list';

import { carComponents, carServices } from '../pages/car';
import { FormsModule }   from '@angular/forms';
//dependence page end
////// page   end
// 引入 Hero 单页面 hero-detail..



import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';

/////service start
import { MyDataProvider } from '../providers/my-data/my-data';
import { HeroServiceProvider } from '../providers/hero-service/hero-service'; //生成頁面自動生成//自動引入。

/////service end
import { HttpModule } from '@angular/http';
//對於    page 沒有引入module.ts,對於 providers 引入進來了.

// mock 离线 api
// Imports for loading & configuring the in-memory web api
import { InMemoryWebApiModule } from 'angular-in-memory-web-api/in-memory-web-api.module';
import { InMemoryDataService } from './in-memory-data.service';

// 新建路由
// import { RouterModule }   from '@angular/router';
import { RouterModule, Routes,Route } from '@angular/router';

// ng 路由
// import { AppRoutingModule } from './app-routing.module';

//  关于ionic 路由的问题
import { LocationStrategy, PathLocationStrategy } from '@angular/common';

import { AppRoutingModule }        from './app-routing.module';



//引入 directive 

import {HighlightDirective} from './highlight.directive'
// import { CarProvider } from '../providers/car/car';


// export const deepLinkConfig = {
//   links: [

//   ]
// };


// ng 路由
const appRoutes: Routes = [
  { path: 'helloIonic', component: HelloIonicPage }
  // { path: 'hero/:id',      component: HeroDetailComponent },
  // {
  //   path: 'heroes',
  //   component: HeroListComponent,
  //   data: { title: 'Heroes List' }
  // },
  // { path: '',
  //   redirectTo: '/heroes',
  //   pathMatch: 'full'
  // },
  // { path: '**', component: PageNotFoundComponent }
];

//新建搜索之后详情页的 ionic 路由
@NgModule({
  declarations: [
    MyApp,
    HelloIonicPage,
    ItemDetailsPage,
    ListPage,
    CeshiPage,
    HerosPage,
    HeroDetailPage,
    TabTestPage,
    Tab1,
    Tab2,
    SearchServicePage,
    SearchDetailPage,
    aboutPage, //404 PAGE
    NgDirectivePage,
    HighlightDirective,  //指令
    DependencyInjectionPage,
    HeroesListComponent,   
    HeroTaxReturnComponent,
    VillainsListComponent,
    carComponents //没有使用指令之前不会报错,使用了之后会报错,需要在生命一下
       //service 不需要进在这里
  ],
  imports: [
    //  RouterModule.forRoot(appRoutes),
    BrowserModule,
    FormsModule,
    // IonicModule.forRoot(MyApp, {
    //   locationStrategy: 'hash'  // 'path', no different   hash     path 。。。有错..进不去以前的路由了
    // }, {
    //     links: [
    //       //404 的网页
    //       { component: aboutPage, name: '404', segment: '*' },     //name没其2效啊...  //换成hash  http://localhost:8100/#/tabs/1 可以进去 但是 不是持久化..马上变成以前的路由
    //       { component: MyApp, name: 'home', segment: 'home' },
    //       { component: HerosPage, segment: 'detail/:user', name: "Heroxxxxxxxxxxxxxxxxxxxx" }, //2层级怎么显示。。。这个只显示一级 。。最后一个detail ====name不起效果
    //       { component: CeshiPage, name: "test" }, //显示name这个路由层级
    //       { component: TabTestPage, name: 'Tabs', segment: 'tabs/:tabId' }, //:tabId 是在tabtestPage component 里定义的
    //       // 配置好的路由 触发由自己的事件去触发。        /#/tabs/1 ===============>>>跳转至tab2
    //       { component: ListPage, name: 'page', segment: 'list', defaultHistory: [TabTestPage] },
    //       //就相当于第一个页面 是这个首页,然后有个返回按钮,不用写ng-if去改变路径了...这里直接改变历史路径
    //       // 如果页面历史堆栈中不存在历史页面的时候，就会返回到这个
    //       // {component:HeroDetailPage,name:'Hero-Detail/:id'}
    //       { component: SearchDetailPage, name: 'Search', segment: 'searchDetail:id' }  //传了一个id
    //     ]

    //   }),
IonicModule.forRoot(MyApp),
    HttpModule,            //引入 记得引入http服务。因为那个页面注入了service层
    InMemoryWebApiModule.forRoot(InMemoryDataService)  //模拟数据  这里就直接调取了数据
  ],
  bootstrap: [IonicApp],
  entryComponents: [  //这是什么compoent  新建的页面不需要再这里引入?
    MyApp,
    HelloIonicPage,
    ItemDetailsPage,
    ListPage,
    CeshiPage,
    HerosPage,
    HeroDetailPage,
    TabTestPage,
    Tab1,
    Tab2,
    SearchServicePage,
    SearchDetailPage,
    aboutPage, //404 PAGE
    NgDirectivePage,
    DependencyInjectionPage          //第一次左边栏的需要在这边注册。。。。。不然要报错 no factory...
  
  ],
  providers: [
    StatusBar,
    SplashScreen,
    { provide: ErrorHandler, useClass: IonicErrorHandler },
    MyDataProvider,
    HeroServiceProvider, //自动添加了service
    // 新增路由
   {provide: LocationStrategy, useClass: PathLocationStrategy}, //这他妈什么都进不去了,
   HeroesService,
    carServices  //不是引入的carprovider 而是引入二级引入的东西
  ]


})

//关于前端存储由于未封装成app,所以不用使用sqlite
export class AppModule { 

  // constructor(router: Router) {
  //   console.log('Routes: ', JSON.stringify(router.config, undefined, 2));
  // }
}
